home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Widget Wizard.dir / WidgtBehaviors_63_Image Switch Cast Members.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  3.4 KB  |  89 lines

  1. property name, setting, Memberalt, MemberOne, GroupName, MemberAltName
  2.  
  3. on setstate me, state, Addressee
  4.   if voidp(Addressee) then
  5.     do_SetState(me, state)
  6.   else
  7.     case Addressee of
  8.       #all:
  9.         do_SetState(me, state)
  10.       (the name of me):
  11.         do_SetState(me, state)
  12.       (the GroupName of me):
  13.         do_SetState(me, state)
  14.     end case
  15.   end if
  16. end
  17.  
  18. on SwitchStates me, Addressee
  19.   if voidp(Addressee) then
  20.     do_SwitchStates(me)
  21.   else
  22.     case Addressee of
  23.       #all:
  24.         do_SwitchStates(me)
  25.       (the name of me):
  26.         do_SwitchStates(me)
  27.       (the GroupName of me):
  28.         do_SwitchStates(me)
  29.     end case
  30.   end if
  31. end
  32.  
  33. on do_SetState me, state
  34.   set the setting of me to state
  35.   if state = 1 then
  36.     set the member of sprite the spriteNum of me to the MemberOne of me
  37.   else
  38.     set the member of sprite the spriteNum of me to the Memberalt of me
  39.   end if
  40. end
  41.  
  42. on do_SwitchStates me
  43.   if the setting of me = 1 then
  44.     set the setting of me to 2
  45.     set the member of sprite the spriteNum of me to the Memberalt of me
  46.   else
  47.     if the setting of me = 2 then
  48.       set the setting of me to 1
  49.       set the member of sprite the spriteNum of me to the MemberOne of me
  50.     end if
  51.   end if
  52.   return the setting of me
  53. end
  54.  
  55. on beginSprite me
  56.   set the MemberOne of me to the member of sprite the spriteNum of me
  57.   set the Memberalt of me to member the MemberAltName of me
  58.   if setting = 1 then
  59.     do_SetState(me, 2)
  60.   else
  61.     do_SetState(me, 1)
  62.   end if
  63. end
  64.  
  65. on getPropertyDescriptionList
  66.   set description to [:]
  67.   if the currentSpriteNum = 0 then
  68.     set memdefault to 0
  69.   else
  70.     set memref to the member of sprite the currentSpriteNum
  71.     set castLibNum to the castLibNum of memref
  72.     set memdefault to member (the memberNum of member memref + 1) of castLib castLibNum
  73.   end if
  74.   addProp(description, #name, [#comment: "Item Name:", #format: #symbol, #default: #twostate1])
  75.   addProp(description, #MemberAltName, [#comment: "Alternate Image Name:", #format: #bitmap, #default: memdefault])
  76.   addProp(description, #setting, [#comment: "Initially Toggled:", #format: #boolean, #default: 0])
  77.   addProp(description, #GroupName, [#comment: "Group Name:", #format: #symbol, #default: #group1])
  78.   return description
  79. end
  80.  
  81. on getBehaviorDescription
  82.   return "Prepares a sprite to display a second bitmap castmember to represent an Alternate state.  State changes are requested by sending the Switch message.  Supports the creation of toggle buttons that can be used together in mutually exclusive multi-item Radio Groups." & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Item Name - ( optional ) name of this control." & RETURN & "ΓÇó Alternate Image - number of castmember whose image will replace normal image.  Must be stored in same cast library as Normal castmember." & RETURN & "ΓÇó Initially Toggled - check this box if sprite's current castmember represents the Alternate rather than the Normal image." & RETURN & "ΓÇó Group Name - ( optional ) name of radio group to which this sprite will belong." & RETURN & "MESSAGES:" & RETURN & "ΓÇó SwitchStates [ID] - show whichever image is not currently visible." & RETURN & "                    - returns the state (0,1) that the sprite becomes." & RETURN & "ΓÇó SetState {0 or 1}, [ID] - Set to Normal Picture or Alternate Picture.  If the ID is omitted any sprite receiving the message will SetState."
  83. end
  84.  
  85. on getAssocMembers
  86.   set myPropList to [MemberAltName]
  87.   return myPropList
  88. end
  89.